package com.manli.api.controller;

import java.util.Arrays;
import java.util.Map;

import com.manli.api.pojo.QueryParamsNoActivityGoods;
import com.manli.api.pojo.QueryParamsRecommendGoods;
import com.manli.api.pojo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import com.manli.api.base.annotation.Permissions;
import com.manli.api.pojo.QueryParams;
import com.manli.api.dto.RecommendGoods;
import com.manli.api.service.RecommendGoodsService;



/**
 * 推荐商品表
 *
 * @author manli
 * @email 
 * @date 2020-08-05 13:28:19
 */
@Api(value="/recommendgoods", tags="推荐商品表")
@RestController
@RequestMapping("api/recommendgoods")
public class RecommendGoodsController {
    @Autowired
    private RecommendGoodsService recommendGoodsService;

    /**
     * 列表
     */
    @ApiOperation(value = "推荐商品表列表",notes = "")
    @PostMapping("/list")
    @Permissions(module = "", privilege = "", typeOfAccess = Permissions.METHOD_OPEN)
    public Result list(@RequestBody QueryParamsRecommendGoods params){
        return recommendGoodsService.queryPage(params);
    }

    /**
     * 根据店铺id获取所有非活动商品的id和名称
     */
    @ApiOperation(value = "根据店铺id获取所有非活动商品",notes = "")
    @PostMapping("/getNoActivityGoods")
    @Permissions(module = "", privilege = "", typeOfAccess = Permissions.METHOD_OPEN)
    public Result getNoActivityGoods(@RequestBody QueryParamsNoActivityGoods params){
        return recommendGoodsService.getNoActivityGoods(params);
    }

    /**
     * 全部数据信息
     */
    @ApiOperation(value = "推荐商品表全部数据信息",notes = "")
    @PostMapping("/all")
    @Permissions(module = "", privilege = "", typeOfAccess = Permissions.METHOD_LOGIN)
    public Result all(){
        return recommendGoodsService.queryAll();
    }

    /**
     * 单条信息
     */
    @ApiOperation(value = "推荐商品表单条信息",notes = "推荐商品表单条信息")
    @GetMapping("/info/{recommendGoodsId}")
    @Permissions(module = "", privilege = "", typeOfAccess = Permissions.METHOD_LOGIN)
    public Result info(@PathVariable("recommendGoodsId") Integer recommendGoodsId){
        return recommendGoodsService.getById(recommendGoodsId);
    }

    /**
     * 保存
     */
    @ApiOperation(value = "推荐商品表保存",notes = "推荐商品表保存")
    @PostMapping("/save")
    @Permissions(module = "", privilege = "", typeOfAccess = Permissions.METHOD_OPEN)
    public Result save(@RequestBody RecommendGoods recommendGoods){
        return recommendGoodsService.save(recommendGoods);
    }

    /**
     * 修改
     */
    @ApiOperation(value = "推荐商品表修改",notes = "推荐商品表修改")
    @PostMapping("/update")
    @Permissions(module = "", privilege = "", typeOfAccess = Permissions.METHOD_OPEN)
    public Result update(@RequestBody RecommendGoods recommendGoods){
        return recommendGoodsService.updateById(recommendGoods);
    }


    /**
     * 删除多条数据
     */
    @ApiOperation(value = "推荐商品表删除",notes = "推荐商品表删除")
    @ApiImplicitParam(name = "recommendGoodsIds", value = "id数组,json字符串",dataType = "id数组,json字符串", required = true)
    @PostMapping("/deleteIds")
    @Permissions(module = "", privilege = "", typeOfAccess = Permissions.METHOD_LOGIN)
    public Result deleteIds(@RequestBody Integer[] recommendGoodsIds){
        return recommendGoodsService.removeByIds(Arrays.asList(recommendGoodsIds));
    }

}
